import edu.sias.mapper.BrandMapper;
import edu.sias.pojo.Brand;
import edu.sias.util.SqlSessionFactoryUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.junit.Test;

import java.util.List;

/**
 * @Auther:横翔
 * @Data:2024/4/22
 * @Project:IntelliJ IDEA
 */
public class TextMapper {
    @Test
    public void selectAll(){
        ////1.创建SqlSessionFactory
        SqlSessionFactory factory
                = SqlSessionFactoryUtils.getSqlSessionFactory();
        //2.获取SqlSession对象
        SqlSession sqlSession = factory.openSession();
        //3.获取BrandMapper
        BrandMapper mapper = sqlSession.getMapper(BrandMapper.class);
        //4.调用方法
        List<Brand> brands = mapper.selectAll();
        //5.释放资源
        sqlSession.close();
        //System.out.println(brands);
        for (int i = 0; i < brands.size(); i++) {
            System.out.println(brands.get(i));
        }
       /* int x = 0;*/
       /* for (Brand i:brands
             ) {
            x++;
            System.out.println(brands.get(x));
        }*/
    }
}
